<?php
include('../../include/functions.inc.php');
include('../../include/inputbuilder.inc.php');
include('../../include/maintenance.inc.php');
if (isEmpty(getParam('ID'))) {
    echo 'WRONG PARAMETER';
} else {
    $maintenance = unserialize($_SESSION['mCargo']);
    $list = $db->query_select("cllg_entity", NULL);
    $rows = $db->query_select($maintenance->table, sprintf("ID=%s", getParam('ID')));

    foreach ($rows as $row) {
        ?>
        <form id="<?php echo $maintenance->formName; ?>" name="<?php echo $maintenance->formName; ?>" method="POST" action="<?php echo $maintenance->updateUrlPage; ?>">
            <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th scope="col"><legend>DATOS MORA</legend></th>
                    <th scope="col" valign="middle">
                        <legend>
                            <div style="margin-left: 30%" class="btn-group">
                                <input type="button" name="cmdOk" id="cmdOk" class="btn btn-info" value="Continuar" onClick="javascript:formOkBt($(this.form),updateAction);jQuery('#cmAddcontainer').show();" />
                                <input type="button" class="btn btn-info" value="Borrar" name="eliminar" id="btneliminar" onclick="javascript:deleteAction('<?php echo $maintenance->deleteUrlPage; ?>',<?php echo $maintenance->getDeleteUrl(); ?>);jQuery('#cmAddcontainer').show();" value="" />
                                <input type="button" name="cmdCancel" id="cmdCancel" class="btn btn-info" value="Cancelar" onClick="loadTable();jQuery('#cmAddcontainer').show()" />
                            </div>
                        </legend>
                    </th>
                </tr>
                <tr>
                    <td colspan="2">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="25%">NOMBRE </td>
                                <td width="75%"><input name="NOMBRE" type="text" id="NOMBRE" value="<?php echo $row['NOMBRE']; ?>" /></td>
                            </tr>
                            <tr>
                                <td>MONTO</td>
                                <td><input name="MONTO" type="text" id="MONTO" value="<?php echo number_format($row['MONTO'], 2, ".", ","); ?>" /></td>
                            </tr>
                            <tr>
                                <td>MORA</td>
                                <td>
                                    <input name="MORA" type="text" id="MORA" value="<?php echo number_format($row['MORA'], 2, ".", ","); ?>"/>
                                    <input type="hidden" name="ID" id="ID" value="<?php echo getParam('ID'); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td>UTILIZAR PARA CHEQUE RECHAZADO</td>
                                <td valign="middle"><input name="CHEQUE_RECHAZADO" type="checkbox" id="CHEQUE_RECHAZADO" value="1" <?php print $row['CHEQUE_RECHAZADO'] == 1 ? ' checked="checked"' : ''; ?> /></td>
                            </tr>
                            <tr>
                                <td>ENTIDAD</td>
                                <td>
                                    <select name="FK_ENTITY" id="FK_ENTITY">
                                        <?php
                                        foreach ($list as $it) {
                                            ?>
                                            <option value="<?php echo $it["ID"]; ?>" 
                                            <?php
                                            if (!(strcmp($it["ID"], $row['FK_ENTITY']))) {
                                                echo "selected=\"selected\"";
                                            }
                                            ?>><?php echo $it["NAME"]; ?></option>
                                                    <?php
                                                }
                                                ?>
                                    </select>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </form>  
        <?php
    }
}
?>